import request from '@/api/request';

export function uploadImage(file: File, module?: string) {
  const formData = new FormData();
  formData.append('file', file);
  if (module) {
    formData.append('module', module);
  }
  return request({
    url: '/api/upload/file',
    method: 'post',
    data: formData,
    headers: { 'Content-Type': 'multipart/form-data' }
  });
}

export function deleteFile(fileId: number) {
  return request({
    url: `/api/upload/file/${fileId}`,
    method: 'delete'
  });
}

export function batchDeleteFiles(fileIds: number[]) {
  return request({
    url: '/api/upload/batch',
    method: 'delete',
    data: fileIds
  });
}

export function getUserFiles(params?: { module?: string }) {
  return request({
    url: '/api/upload/list',
    method: 'get',
    params
  });
}